<?php
/*
 * Taken from http://www.openhosting.co.uk/articles/serverside/5802/
 */
function allowChars($strValue, $strChars, $blnCaseSense)  {
	$strResult = "";  
	if ($blnCaseSense) {
		for ($i = 0; $i < strlen($strValue); $i++) {
			$strChar = substr($strValue, $i, 1);
			if (is_numeric(strpos($strChars, $strChar))) { 
				$strResult .= $strChar; 
			}
		}
	}
	else {
		$strChars = strtoupper($strChars);
		for ($i = 0; $i < strlen($strValue); $i++) {      
			$strChar = substr($strValue, $i, 1);
			if (is_numeric(strpos($strChars, strtoupper($strChar)))) { 
				$strResult .= $strChar; 
			}
		}
	}
	return $strResult;
}

	function getGuid()  {  
		#  # First try and use the Windows-specific guaranteed method  #  
		if (!$objGuid = @new COM("Scriptlet.TypeLib")) {   
			#    # Couldn't create the object (non-Windows server) so use the other method    #   
			$strGuid = md5(uniqid(rand(), 1));
		}  
		else {    
			#    # Created the object so use the GUID property and strip unwanted chars    #    
			$strGuid = allowChars(strtolower($objGuid->GUID()), "0123456789abcdef", false);
		}  
		$objGuid = null;  
		return $strGuid;  
	}
?>